package io.sunny.platform.mcp.application.service.impl;

import io.sunny.platform.mcp.application.service.BookService;
import io.sunny.platform.mcp.domain.model.Book;
import io.sunny.platform.mcp.domain.repository.BookRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author SUNNY
 * @Date 2025/12/3 18:57
 * @PackageName: io.sunny.platform.agent.mcp.application.service.impl
 * @Description: TODO
 * @Version 1.0
 */
@Slf4j
@Service
public class BookServiceImpl implements BookService {

    private final BookRepository bookRepository;

    @Autowired
    public BookServiceImpl(BookRepository bookRepository) {
        this.bookRepository = bookRepository;
    }


    @Override
    @Tool(name = "findBooksByAuthor", description = "根据作者精确查询图书")
    public List<Book> findBooksByAuthor(String author) {
        log.info("findBooksByAuthor: {}", author);
        return bookRepository.findBooksByAuthor(author);
    }

    @Override
    @Tool(name = "findBooksByCategory", description = "根据图书分类精确查询图书")
    public List<Book> findBooksByCategory(String category) {
        log.info("findBooksByCategory: {}", category);
        return bookRepository.findBooksByCategory(category);
    }
}
